package dao

import (
	"fmt"
	"log"
	"permange/pkg/setting"

	"gorm.io/driver/postgres"
	"gorm.io/gorm"
)

var db *gorm.DB

func Setup() {
	var err error
	dsn := fmt.Sprintf("user=%s password=liu123456 dbname=soft host=127.0.0.1 port=5432 sslmode=disable TimeZone=Asia/Shanghai",
		setting.DatabaseSetting.User,
	)

	db, err = gorm.Open(postgres.Open(dsn), &gorm.Config{})

	if err != nil {
		log.Fatalf("models.Setup err:%v", err)
	}
}
